package com.sqx.modules.errand.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqx.common.utils.Result;
import com.sqx.modules.errand.dao.ErrandEvaluateDao;
import com.sqx.modules.errand.dao.TbIndentDao;
import com.sqx.modules.errand.entity.ErrandEvaluate;
import com.sqx.modules.errand.entity.TbIndent;
import com.sqx.modules.errand.service.ErrandEvaluateService;
import com.sqx.modules.order.entity.Evaluate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

@Service
public class ErrandEvaluateServiceImpl extends ServiceImpl<ErrandEvaluateDao, ErrandEvaluate> implements ErrandEvaluateService {

    @Autowired
    private ErrandEvaluateDao errandEvaluateDao;
    @Autowired
    private TbIndentDao tbIndentDao;

    @Override
    public Result userEvaluate(Long userId, ErrandEvaluate evaluate) {
        TbIndent indent = tbIndentDao.selectIndentByIndentNumber(evaluate.getIndentNumber());
        errandEvaluateDao.userEvaluate(userId, indent.getRiderUserId(), evaluate.getIndentNumber(), evaluate.getEvaluateMessage(),
                evaluate.getSatisfactionFlag(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        return Result.success();
    }

}
